const SMSClient = require('@alicloud/sms-sdk');

// https://usercenter.console.aliyun.com/#/manage/ak
// const accessKeyId = 'LTAIZQoVVoPuBjU9'
const accessKeyId = 'LTAI4FbvV4zJj2rWNJcBACNP'
// const secretAccessKey = 'GfJuI2dLsCQh7Q56TmFxPTniXjkVnB'
const secretAccessKey = 'iQ91AQMhhVkXRqcZtkjqPkOtzOZFdd'

let smsClient = new SMSClient({accessKeyId, secretAccessKey})

module.exports = {
    send (PhoneNumbers, code) {
        return new Promise((resolve, reject) => {
            smsClient.sendSMS({
                PhoneNumbers: PhoneNumbers,
                SignName: '吴勋勋',//按照严格意义来说，此处的签名和模板的ID都是可变的
                SignName: '乐乐的博客',//按照严格意义来说，此处的签名和模板的ID都是可变的
                // TemplateCode: 'SMS_111785721',
                TemplateCode: 'SMS_181862123',
                TemplateParam: `{code:${code}}`
            }).then(function (res) {
                let {Code}=res
                if (Code === 'OK') {
                    console.log(Code)
                    //处理返回参数
                   resolve()
                }
            }, function (err) {
                reject(err)
            })
        })
    }
}